<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>单品统计</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="{{asset('/layuiadmin/layui/css/layui.css')}}" media="all">
    <link rel="stylesheet" href="{{asset('/layuiadmin/style/admin.css')}}" media="all">
    <style>
        .edit{background-color: #ed9c3a;}
        .shenhe{background-color: #429488;}
        .see{background-color: #7cb717;}
        .tongbu{background-color: #4c9ef8;color:#fff;border-radius:3.5px}
        .cur{color:#21c4f5;}
        .userbox,.storebox{height:190px;margin-right:0; overflow-y: auto; z-index: 999; position: absolute; left: 0px; top: 63px; width:298px; background-color:#ffffff; border: 1px solid #ddd;}
        .userbox .list,.storebox .list{height:38px;line-height: 38px;cursor:pointer; padding-left:10px;}
        .userbox .list:hover,.storebox .list:hover{background-color:#eeeeee;}
        .yname{font-size: 13px; color: #444; margin-bottom:8px;}
    </style>
</head>
<body>

<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12" style="margin-top:0px">
            <div class="layui-fluid">
                <div class="layui-row layui-col-space15">
                    <div class="layui-col-md12">
                        <div class="layui-card">
                            <div class="layui-card-header">对账汇总</div>
                            <div class="layui-card-body">
                                <div class="layui-btn-container" style="font-size:14px;">
                                    <!-- 选择业务员 -->
                                    <!-- <div class="layui-form" lay-filter="component-form-group" style="width:190px;margin-right:0;display: block;">
                                      <div class="layui-form-item">
                                        <div class="layui-input-block" style="margin-left:5px;border-radius:5px">
                                            <select name="agent" id="agent" lay-filter="agent" lay-search>
                                            </select>
                                        </div>
                                      </div>
                                    </div> -->
                                    <div style="font-size:14px">
                                        <div class="layui-form" lay-filter="component-form-group" style="width: 100%;margin-right:0;display: inline-block;">
                                            <div class="layui-form-item">
                                                <div class="layui-input-block" style="margin-left:5px;border-radius:5px">



                                                    <div class="layui-inline">
                                                        <div class="layui-input-inline">
                                                            <text class="yname">门店ID</text>
                                                            <input type="text" class="layui-input store_id test-item" placeholder="门店名称">
                                                        </div>
                                                    </div>

                                                    <div class="layui-inline">
                                                        <div class="layui-input-inline">
                                                            <text class="yname">交易开始时间</text>
                                                            <input type="text" class="layui-input start-item test-item" placeholder="交易开始时间" lay-key="23">
                                                        </div>
                                                    </div>
                                                    <div class="layui-inline">
                                                        <div class="layui-input-inline">
                                                            <text class="yname">交易结束时间</text>
                                                            <input type="text" class="layui-input end-item test-item" placeholder="交易结束时间" lay-key="24">
                                                        </div>
                                                    </div>



                                                    <div class="layui-inline">
                                                        <button class="layui-btn layui-btn-normal" style="border-radius:5px;margin-top:31px;" id="search">搜索</button>

                                                        <button class="layui-btn export" style="border-radius:5px;margin-top:31px;">导出</button>
                                                    </div>

                                                </div>



                                            </div>
                                        </div>
                                    </div>
                                </div>

                                <table class="layui-hide" id="test-table-page" lay-filter="test-table-page"></table>


                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<script src="{{asset('/layuiadmin/layui/layui.js')}}"></script>
<script>
    var token = localStorage.getItem("Publictoken");
    var str=location.search;
    var store_id=str.split('?')[1];

    layui.config({
        base: '../../layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index','form','table','laydate'], function(){
        var $ = layui.$
            ,admin = layui.admin
            ,form = layui.form
            ,table = layui.table
            ,laydate = layui.laydate;

        $('.store_id').val(store_id);

        // 未登录,跳转登录页面
        $(document).ready(function(){
            if(token==null){
                window.location.href="{{url('/mb/login')}}";
            }
        });




        $('.export').click(function(){
            window.location.href="{{url('/api/merchant/goods_count')}}" + "?export=1&token=" + token + "&time_start=" + $('.start-item').val() + "&time_end=" + $('.end-item').val();
        });
        laydate.render({
            elem: '.start-item'
            ,type: 'date'
            ,done: function(value){
                //执行重载
            }
        });

        laydate.render({
            elem: '.end-item'
            ,type: 'date'
            ,done: function(value){
                //执行重载
            }
        });

        // 搜索
        $('#search').click(function(){
            // 渲染表格
            var pageLoading = layer.msg('数据请求中..', {
                icon: 16
                ,shade: 0.3
                ,time: false
            });
            table.render({
                elem: '#test-table-page',
                url: "{{url('/api/merchant/goods_count')}}",
                method: 'post',
                where:{
                    token: token,
                    store_id: $('.store_id').val(),
                    time_start: $('.start-item').val(),
                    time_end: $('.end-item').val(),
                    user_id: $('.user_id').val(),
                },
                request: {
                    pageName: 'p',
                    limitName: 'l'
                },
                page: true,
                cellMinWidth: 100,
                cols: [[
                    {field: 'store_id', align: 'left', title: '门店id'},
                    {field: 'store_name', align: 'left', title: '门店名称'},
                    {field: 'out_trade_no', align: 'left', title: '订单号'},
                    {field: 'coupon_name', align: 'left', title: '单品名称'},
                    {field: 'num', align: 'left', title: '核销数量'},
                    {field: 'coupon_type', align: 'left', title: '优惠类型'},
                    {field: 'cost', align: 'left', title: '单品费用'},
                    {field: 'company', align: 'left', title: '通道'},
                ]],
                response: {
                    statusName: 'status', //数据状态的字段名称，默认：code
                    statusCode: 1, //成功的状态码，默认：0
                    msgName: 'message', //状态信息的字段名称，默认：msg
                    countName: 't', //数据总数的字段名称，默认：count
                    dataName: 'data', //数据列表的字段名称，默认：data
                },
                done: function(res, curr, count){
                    $('th').css({'font-weight': 'bold', 'font-size': '15','color': 'black','background':'linear-gradient(#f2f2f2,#cfcfcf)'});	//进行表头样式设置
                    if(pageLoading){
                        layer.close(pageLoading);
                    }
                    
                }
            });

        });

    });
</script>

</body>
</html>